<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="旧件报表" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="search-bar wrapper-none col-xs-12">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                            ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <div class="btn btn-default base-color" ng-if="!!btnPermission.secondHandExport">
                            <div title="导出">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                            <ul class="more-tool">
                                <!-- <li yb-download download-url="exportParam.sectionUrl" download-param="exportParam.sectionParam"
                                    download-key="ids">
                                    <i class="yb-icon ico-export-o"></i> 导出
                                </li> -->
                                <li yb-download download-url="exportParam.allUrl" download-param="condition"
                                    download-duration="3">
                                    <i class="yb-icon ico-export-o"></i> 导出全部
                                </li>
                            </ul>
                        </div>
                    </div>
                    <button class="btn-advance pull-right m-l-xs"
                        ng-click="switchToolbar('AdvanceSearch')">高级搜索</button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="单据号"
                            ng-model="condition.businessNo">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
                    </div>
                </div>
                <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)"
                    reset-data="reset()">
                    <div class="advance-search m-t-sm">
                        <div class="form-group clearfix">
                            <label class="control-label">单据号：</label>
                            <input type="text" name="businessNo" ng-model="condition.businessNo" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">零件编号：</label>
                            <input type="text" name="materialNo" ng-model="condition.materialNo" class="form-control">
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label">创建时间：</label>
                            <input type="text" class="form-control date-picker" ng-model="condition.beginDate"
                                datepicker-popup="{{'yyyy-MM-dd'}}"
                                ng-click="showDatepickerBegin = !showDatepickerBegin"
                                ng-change="checkDate(condition, 'beginDate', 'endDate')" is-open="showDatepickerBegin"
                                close-text="关闭" modal-size="small" readonly>
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label"></label>
                            <label class="control-label wave-line">~</label>
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label"></label>
                            <input type="text" class="form-control date-picker" ng-model="condition.endDate"
                                datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="showDatepickerEnd = !showDatepickerEnd"
                                ng-change="checkDate(condition, 'beginDate', 'endDate')" is-open="showDatepickerEnd"
                                close-text="关闭" modal-size="small" readonly>
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">状态：</label>
                            <select class="form-control" ng-model="condition.returnStatus">
                                <option value="">请选择</option>
                                <option value="0">未发货</option>
                                <option value="1">已发货</option>
                                <option value="2">已收货</option>
                            </select>
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">备件指令单号：</label>
                            <input type="text" ng-model="condition.crmOrder" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">服务信息单号：</label>
                            <input type="text" ng-model="condition.serviceNo " class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">服务人员名称：</label>
                            <input type="text" ng-model="condition.serviceName" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">服务网点：</label>
                            <input type="text" ng-model="condition.serviceSite" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tbConf" col-fixed="true"
                has-check-col="true"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap" ele-count="4" scroll-area="right">


                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-click="toSort(tbConf.tableCol, $index)"
                                        ng-show="!!itemCol.isShow && !!itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tbConf.fixedWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>


                    <div class="th-scroll-x" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-click="toSort(tbConf.tableCol, $index)"
                                        ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>


                    <div class="td-scroll" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.curRow}"
                                    ng-click="selectRow($index)">
                                    <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="!itemCol.clickFn && itemCol.type !== 'operate'">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <div class="font-0" ng-if="itemCol.type == 'operate'">
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="posting(item,0)"
                                                ng-disabled="!btnPermission.secondHandOut || item.returnStatus == 1 || item.returnStatus == 2"
                                                title="{{!btnPermission.secondHandOut?'无权限执行此操作':''}}">
                                                发货
                                            </button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="posting(item,1)"
                                                ng-disabled="!btnPermission.secondHandIn || item.returnStatus == 2"
                                                title="{{!btnPermission.secondHandIn?'无权限执行此操作':''}}">
                                                收货
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>


                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.curRow}"
                                    ng-click="selectRow($index)">
                                    <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="!itemCol.clickFn && itemCol.type !== 'operate' && itemCol.type !== 'wornreturnRemark'">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <div class="font-0" ng-if="itemCol.type == 'operate'">
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="posting(item,0)"
                                                ng-disabled="!btnPermission.secondHandOut || item.returnStatus == 1 || item.returnStatus == 2"
                                                title="{{!btnPermission.secondHandOut?'无权限执行此操作':''}}">
                                                发货
                                            </button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="posting(item,1)"
                                                ng-disabled="!btnPermission.secondHandIn || item.returnStatus == 2"
                                                title="{{!btnPermission.secondHandIn?'无权限执行此操作':''}}">
                                                收货
                                            </button>
                                        </div>
                                        <div ng-if="itemCol.type === 'wornreturnRemark'" class="td-edit pos-r"
                                            title="{{item[itemCol.dataField]}}">
                                            <div class="date-picker-div1">
                                                <input ng-if="!!btnPermission.secondHandRemark"  type="text" name="wornreturnRemark" class="form-control" ng-model="item.wornreturnRemark" maxlength="200">
                                            </div>
                                            <div class="date-picker-div2">
                                                <a ng-if="!!btnPermission.secondHandRemark" class="btn-operate m-r-xs" ng-click="changeWornOutRemark(item)" >
                                                    提交
                                                </a>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>
        <div tab heading="{{tabFlag.name}}" active="activeFlag[1]" ng-if="activeFlag[1]">
            <div class="main-area d-t-35 d-b-60">
                <form name="form" class="main-wrap form-horizontal single-col p-t clearfix" novalidate>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"><i>*</i>单据类型：</label>
                        <div class="col-xs-5 wrapper-none">
                            <input type="text" name="type" class="form-control" ng-model="detailInfo.type" required
                                yb-focus maxlength="30">
                        </div>
                        <div class="col-xs-4 msg-block" ng-show="form.type.$dirty || (form.type.$invalid && submitted)">
                            <div class="error-msg" ng-if="form.type.$error.required && !form.type.focused">
                                <i class="yb-icon ico-times-circular"></i>必填项，请填写
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"><i ng-show="detailInfo.isSynsap === 1">*</i>内部订单：</label>
                        <div class="col-xs-5 wrapper-none">
                            <ul class="row">
                                <li class="m-b-xs clearfix pos-r"
                                    ng-repeat="item in detailInfo.detailList track by $index">
                                    <input type="text" name="innerOrder{{$index}}" class="form-control pull-left m-r-xs"
                                        style="width: 35%;" ng-model="item.innerOrder" maxlength="30" placeholder="订单号"
                                        ng-required="detailInfo.isSynsap === 1">
                                    <input type="text" name="" class="form-control pull-left m-r-xs" style="width: 55%;"
                                        ng-model="item.innerOrderNote" maxlength="50" placeholder="订单说明"
                                        ng-required="detailInfo.isSynsap === 1">
                                    <i class="yb-icon ico-minus-o pull-left cursor-pointer info-color"
                                        ng-click="minusInnerOrder($index)"
                                        ng-show="(detailInfo.detailList.length > 1) && ($index < (detailInfo.detailList.length - 1))"
                                        style="font-size: 24px;line-height: 34px;"></i>
                                    <i class="yb-icon ico-plus-o pull-left cursor-pointer info-color"
                                        ng-click="plusInnerOrder()"
                                        ng-show="(detailInfo.detailList.length === 0) || ($index === (detailInfo.detailList.length - 1))"
                                        style="font-size: 24px;line-height: 34px;"></i>
                                    <div class="msg-block pos-a col-xs-5" style="left: 100%"
                                        ng-show="(detailInfo.isSynsap === 1) && (!item.innerOrder || !item.innerOrderNote) && submitted">
                                        <div class="error-msg">
                                            <i class="yb-icon ico-times-circular"></i>必填项，请填写
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="form-group m-b-xs">
                        <label class="col-xs-2 control-label">移动类型：</label>
                        <div class="col-xs-5 wrapper-none">
                            <input type="text" name="moveType" class="form-control" ng-model="detailInfo.moveType"
                                maxlength="30">
                        </div>
                    </div>
                    <div class="form-group m-b-xs">
                        <label class="col-xs-2 control-label">出/入库：</label>
                        <label class="col-xs-5 control-label p-l-n text-left">
                            <input type="radio" class="m-r-md pull-left" yb-radio ng-model="detailInfo.inOut" value="0"
                                yb-radio-name="入库类型">
                            <input type="radio" class="m-r-md pull-left" yb-radio ng-model="detailInfo.inOut" value="1"
                                yb-radio-name="出库类型">
                        </label>
                    </div>
                    <div class="form-group m-b-xs">
                        <label class="col-xs-2 control-label">是否同步SAP：</label>
                        <label class="col-xs-5 control-label p-l-n text-left">
                            <input type="radio" class="m-r-md pull-left" yb-radio ng-model="detailInfo.isSynsap"
                                value="1" yb-radio-name="是">
                            <input type="radio" class="m-r-md pull-left" yb-radio ng-model="detailInfo.isSynsap"
                                value="0" yb-radio-name="否">
                        </label>
                    </div>
                    <div class="form-group save-bar m-b-none">
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-5 wrapper-none">
                            <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData(form.$valid)">
                                保存
                            </button>
                            <button type="button" class="btn btn-default" ng-click="changeTab(0)">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>